//
//  HXQYQueryListBarMenuView.m
//  KD
//
//  Created by 梅洋 on 16/8/3.
//  Copyright © 2016年 Whx. All rights reserved.
//

#import "HXQYQueryListBarMenuView.h"

@interface HXQYQueryListBarMenuView ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong) NSArray <HXGetAreaOrKindListModel *>* dataArray;

@end

@implementation HXQYQueryListBarMenuView

-(instancetype)initWithFrame:(CGRect)frame
               withDataArray:(NSArray <HXGetAreaOrKindListModel *>*)dataArray{

    if ([super initWithFrame:frame]) {
        
        self.dataSource = self;
        self.delegate   = self;
        self.dataArray = dataArray;
    }
    
    return self;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return self.dataArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCellMenu"];
    
    if (cell == nil) {
        
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"UITableViewCellMenu"];
    }
    
    cell.textLabel.text = self.dataArray[indexPath.row].typeName;
    
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    _block(self.dataArray[indexPath.row]);
}

-(void)ReturnGetAreaOrKindListModel:(ReturnGetAreaOrKindListModel)block{

    _block = block;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
